
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;

entity Matiastop is
   port(     
      pulsador       : in  std_logic_vector(3 downto 0);    
      xtal           : in  std_logic;
      enable         : in  std_logic;
      Xin            : in  std_logic_vector(15 downto 0);
      Yin            : in  std_logic_vector(15 downto 0);
      Zin            : in  std_logic_vector(15 downto 0);
		vsinc_o	 		: out std_logic;
		hsinc_o	 		: out std_logic;
		red_o		  		: out std_logic;
	   green_o	 		: out std_logic;
	   blue_o	  		: out std_logic
   );
end Matiastop;

architecture Behavioral of Matiastop is

	component rotador3d is
		port(     
			pulsador         : in  std_logic_vector(5 downto 0);    
			xtal             : in  std_logic;
			enable           : in  std_logic;
			Xin              : in  std_logic_vector(14 downto 0);
			Yin              : in  std_logic_vector(14 downto 0);
			Zin              : in  std_logic_vector(14 downto 0);
			Yout             : out std_logic_vector(8 downto 0);
			Zout             : out std_logic_vector(8 downto 0);
			reset            : out std_logic
   );
	end component;
	component Mundo is
    port ( vsinc_o	 	: out std_logic;
	        hsinc_o	 	: out std_logic;
	        red_o		  	: out std_logic;
	        green_o	 	: out std_logic;
	        blue_o	  		: out std_logic;
	        reset    		: in std_logic;
	        Yin      		: in std_logic_vector(8 downto 0);
	 		  Zin      		: in std_logic_vector(8 downto 0);
	        xtal_i   		: in std_logic
	 );
	 end component;


	 signal P 		: 	std_logic_vector (5 downto 0):="000000";
	 signal YR2M	:	std_logic_vector(8 downto 0);
	 signal ZR2M	:	std_logic_vector(8 downto 0);
	 signal rst		:	std_logic:='0';


	begin

	 
	 	 P(0)    <= pulsador(0) and not(pulsador(3));
       P(1)    <= pulsador(1) and not(pulsador(3));
       P(2)    <= pulsador(2) and not(pulsador(3));
       P(3)    <= pulsador(0) and pulsador(3);
       P(4)    <= pulsador(1) and pulsador(3);
       P(5)    <= pulsador(2) and pulsador(3);
		 
		rtdr:		rotador3d 	port map(P,xtal,enable,Xin(14 downto 0),Yin(14 downto 0),Zin(14 downto 0),YR2M,ZR2M,rst);
		mnd:		mundo			port map(vsinc_o,hsinc_o,red_o,green_o,blue_o,rst,YR2M,ZR2M,xtal);

	 

end Behavioral;

